﻿CREATE TABLE [dbo].[Departamente] (
    [Cod]                VARCHAR (20)    NULL,
    [Activ]              BIT             NULL,
    [IDDepartament]      INT             IDENTITY (1, 1) NOT NULL,
    [CodUnitate]         SMALLINT        CONSTRAINT [DF_Departamente_CodUnitate] DEFAULT ((0)) NOT NULL,
    [IDTipDepartament]   INT             CONSTRAINT [DF_Departamente_IDTipDepartament] DEFAULT ((0)) NOT NULL,
    [IDDepartParinte]    INT             CONSTRAINT [DF_Departamente_IDDepartParinte] DEFAULT ((0)) NOT NULL,
    [Nume]               VARCHAR (150)   NULL,
    [IDJurnal]           INT             NULL,
    [NumericField]       DECIMAL (10, 2) NULL,
    [IDGestionar]        INT             NULL,
    [Suprafata]          DECIMAL (10, 2) CONSTRAINT [DF_Departamente_Suprafata] DEFAULT ((0)) NULL,
    [ExecutieCheltuieli] BIT             DEFAULT ((0)) NOT NULL,
    [Ordine]             SMALLINT        DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_Departamente] PRIMARY KEY CLUSTERED ([IDDepartament] ASC),
    CONSTRAINT [FK_Departamente_Gestionari] FOREIGN KEY ([IDGestionar]) REFERENCES [dbo].[Gestionari] ([IDGestionar]),
    CONSTRAINT [FK_Departamente_Jurnale] FOREIGN KEY ([IDJurnal]) REFERENCES [dbo].[Jurnale] ([IDJurnal]),
    CONSTRAINT [FK_Departamente_TipDepartament] FOREIGN KEY ([IDTipDepartament]) REFERENCES [dbo].[TipDepartament] ([IDTipDepartament]),
    CONSTRAINT [FK_Departamente_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

